home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 1 / BBS in a box - Trilogy I.iso / Files / Publish / A / Alpha.5.58 / Tcl / UserCode / latex.tcl < prev    next >
Encoding:
Text File  |  1993-11-10  |  54.3 KB  |  2,522 lines  |  [TEXT/ALFA]

  1. #############################################################################
  2. #
  3. # latex.tcl:  macros and bindings for LaTeX users
  4. #
  5. # -- see files 'LaTeX Help' and 'commands.tex' in the Help folder
  6. #
  7. #############################################################################
  8. #
  9. # version 1.1 and 1.2 (11/10/92) by Richard T. Austin (austin@eecs.umich.edu)
  10. # version 2.0 (1/24/93) by Tom Scavo (scavo@cie.uoregon.edu)
  11. #
  12. # If you make improvements to this file, please share them!
  13. #
  14. #############################################################################
  15.  
  16. source ":Tcl:UserCode:smart.tcl"
  17.  
  18. #############################################################################
  19. #
  20. # Flags and Variables.
  21. #
  22. #############################################################################
  23.  
  24. set true 1
  25. set false 0
  26. # set insertLatexParameter $true
  27. # set noInsertLatexParameter $false
  28.  
  29. initTclFlag useBoxMacro
  30. initTclFlag deleteObjectNoisily
  31. initTclFlag deleteEnvironmentNoisily
  32. set useBoxMacro $true
  33. set deleteObjectNoisily $false
  34. set deleteEnvironmentNoisily $true
  35. initTclVar boxMacroName
  36. set boxMacroName "BoxedEPSF"
  37.  
  38.  
  39. #############################################################################
  40. #
  41. # Utility Macros.
  42. #
  43. #############################################################################
  44.  
  45. # A boolean function which checks to see if there's a current selection.
  46. proc isSelection {} {
  47.     return [string length [getSelect]]
  48. }
  49.  
  50. # Select the line containing the insertion point.
  51. proc lineSelect {} {
  52.     goto [lineStart [getPos]]
  53.     nextLineSelect
  54. }
  55.  
  56. # A boolean function which takes any string and tests to see if
  57. # that string contains all whitespace characters.  Carriage returns 
  58. # are considered whitespace, as are spaces and tabs.
  59. proc isWhitespace {anyString} {
  60.     set len [string length $anyString]
  61.     for {set i 0} {$i < $len} {incr i} {
  62.         set c [string index $anyString $i]
  63.         if {($c != "\ ") && ($c != "\t") && ($c != "\r")} then {return 0}
  64.     }
  65.     return 1
  66. }
  67.  
  68. # Insert a carriage return at the insertion point if any
  69. # character preceding the insertion point (on the same line)
  70. # is a non-whitespace character.
  71. proc openingCarriageReturn {} {
  72.     set end [getPos]
  73.     set start [lineStart $end]
  74.     set text [getText $start $end]
  75.     if {![isWhitespace $text]} carriageReturn
  76. }
  77.  
  78. # Insert a carriage return at the insertion point if any
  79. # character following the insertion point (on the same line)
  80. # is a non-whitespace character.
  81. proc closingCarriageReturn {} {
  82.     set start [getPos]
  83.     set end [nextLineStart $start]
  84.     set text [getText $start $end]
  85.     if {![isWhitespace $text]} carriageReturn
  86. }
  87.  
  88. # Set up tab stop mechanism.
  89. proc gotoTabStop {directionIndicator} {
  90.     set searchResult [search -n -f $directionIndicator -m 0 -i 1 -r 0 {•} [getPos]]
  91.     if {[llength $searchResult] == 0} then {
  92.         message "tab stop not found"
  93.         return 0
  94.     } else {
  95.         goto [lindex $searchResult 0]
  96.         return 1
  97.     }
  98. }
  99. proc nextTabStop {} {
  100.     if {[gotoTabStop 1]} {deleteChar}
  101. }
  102. proc previousTabStop {} {
  103.     if {[gotoTabStop 0]} {deleteChar}
  104. }
  105.  
  106. # Insert an object at the insertion point. If there is a selection and the 
  107. # global variable deleteObjectNoisily is false, quietly delete the selection 
  108. # first (just like "paste"). Otherwise, prompt the user for the appropriate 
  109. # action. Returns true if the object is ultimately inserted, and false if the 
  110. # user cancels the operation. 
  111. proc insertObject {objectName} {
  112.     global deleteObjectNoisily
  113.     if {[isSelection]} then {
  114.         if {$deleteObjectNoisily} then {
  115.             case [askyesno "Delete selection?"] in {
  116.                 "yes" {deleteText [getPos] [selEnd]}
  117.                 "no" {backwardChar}
  118.                 "cancel" {return 0}
  119.             }
  120.         } else {
  121.             deleteText [getPos] [selEnd]
  122.         }
  123.     }
  124.     insertText $objectName
  125.     return 1
  126. }
  127.  
  128. # Insert an object at the insertion point. If there is a selection, wrap 
  129. # it inside the parameters $left and $right. Returns true if there is a 
  130. # selection (in which case it will wrap), and false otherwise. 
  131. proc wrapObject {left right} {
  132.     set currentPos [getPos]
  133.     set selected [isSelection]
  134.     if {$selected} then {
  135.         replaceText $currentPos [selEnd] $left [getSelect] $right
  136.     } else {
  137.         insertText $left "•" $right
  138.     }
  139.     goto $currentPos
  140.     nextTabStop
  141.     return $selected
  142. }
  143.  
  144. # Inserts an environment with the specified name at the insertion point. 
  145. # Preserves indentation, and positions the cursor at the beginning of the 
  146. # environment body (to be inserted by the calling procedure). If the 
  147. # parameter latexParameter is true, a LaTeX parameter is inserted and the 
  148. # cursor is positioned there instead. Deletes the current selection quietly 
  149. # if the global variable deleteEnvironmentNoisily is false; otherwise the 
  150. # user is prompted for directions. Returns true if the environment is 
  151. # ultimately inserted, and false if the user cancels the operation. 
  152. proc insertEnvironment {environmentName latexParameter} {
  153.     global deleteEnvironmentNoisily
  154.     if {[isSelection]} then {
  155.         if {$deleteEnvironmentNoisily} then {
  156.             case [askyesno "Delete selection?"] in {
  157.                 "yes" {deleteText [getPos] [selEnd]}
  158.                 "no" {backwardChar}
  159.                 "cancel" {return 0}
  160.             }
  161.         } else {
  162.             deleteText [getPos] [selEnd]
  163.         }
  164.     }
  165.     set currentPos [getPos]
  166.     openingCarriageReturn
  167.     insertText "\\begin{" $environmentName "}"
  168.     # insert optional LaTeX parameter here:
  169.     if {$latexParameter} {insertText "{•}"}
  170.     carriageReturn
  171.     tab
  172.     insertText "•"
  173.     carriageReturn
  174.     backwardChar
  175.     deleteChar
  176.     insertText "\\end{" $environmentName "}•"
  177.     closingCarriageReturn
  178.     goto $currentPos
  179.     nextTabStop
  180.     return 1
  181. }
  182.  
  183. # Insert an environment with the given name at the insertion point. If there 
  184. # is currently a selection, cut and paste it into the body of the new 
  185. # environment, indent it, and leave it highlighted. Returns true if there is 
  186. # a selection, and false otherwise. 
  187. proc wrapEnvironment {environmentName latexParameter} {
  188.     if {[isSelection]} then {
  189.         set indent [indentString [getPos]]
  190.         set text [getSelect]
  191.         deleteText [getPos] [selEnd]
  192.         insertText $indent "\r"
  193.         backwardChar
  194.         insertEnvironment $environmentName $latexParameter
  195.         if {$latexParameter} then {
  196.             insertText "•"
  197.             nextTabStop
  198.         }
  199.         lineSelect
  200.         clear
  201.         insertText $text
  202.         markHilite
  203.         shiftRightRegion
  204.         return 1
  205.     } else {
  206.         insertEnvironment $environmentName $latexParameter
  207.         return 0
  208.     }
  209. }
  210.  
  211.  
  212. #############################################################################
  213. # Paragraph Mode Macros.
  214. #
  215. #############################################################################
  216.  
  217. # Documents:
  218. proc insertDocument {documentType} {
  219.     set currentPos [getPos]
  220.     insertText "\\documentstyle\[•\]{$documentType}"
  221.     carriageReturn
  222.     insertEnvironment "document" 0
  223.     backwardChar
  224.     deleteChar
  225.     carriageReturn
  226.     insertText "•"
  227.     carriageReturn
  228.     nextTabStop
  229.     carriageReturn
  230.     goto $currentPos
  231.     nextTabStop
  232. }
  233. proc isDocumentSelected {} {
  234.     return 1
  235. }
  236. proc isEmptyFile {} {
  237.     return 1
  238. }
  239. proc wrapDocument {documentType} {
  240.     if {[isSelection]} then {
  241.         if {[isDocumentSelected]} then {
  242.             set text [getSelect]
  243.             deleteText [getPos] [selEnd]
  244.         } else {
  245.             case [askyesno "Select entire document?"] in {
  246.                 "yes" {}
  247.                 "no" {
  248.                     set text [getSelect]
  249.                     deleteText [getPos] [selEnd]
  250.                 }
  251.                 "cancel" {return 0}
  252.             }
  253.         }
  254.         set currentPos [getPos]
  255.         insertDocument $documentType
  256.         insertText "•"
  257.         nextTabStop
  258.         lineSelect
  259.         clear
  260.         insertText $text
  261.         markHilite
  262.         nextTabStop
  263.     } else {
  264.         if {![isEmptyFile]} then {
  265.             case [askyesno "Wrap existing text?"] in {
  266.                 "yes" {}
  267.                 "no" {}
  268.                 "cancel" {return 0}
  269.             }
  270.         }
  271.         insertDocument $documentType
  272.     }
  273.     return 1
  274. }
  275.  
  276. proc letter {} {
  277.     wrapDocument "letter"
  278.     message "type style option(s)"
  279. }
  280. proc article {} {
  281.     wrapDocument "article"
  282.     message "type style option(s)"
  283. }
  284. proc report {} {
  285.     wrapDocument "report"
  286.     message "type style option(s)"
  287. }
  288. proc book {} {
  289.     wrapDocument "book"
  290.     message "type style option(s)"
  291. }
  292.  
  293. proc custom {} {
  294.     catch {prompt "What document type?" "article"} documentType
  295.     if {$documentType != "cancel"} then {
  296.         wrapDocument $documentType
  297.         message "type style option(s)"
  298.     }
  299. }
  300.  
  301. # Sectioning:
  302. proc part {} {
  303.     if {[wrapObject "\\part{" "}•"]} then {
  304.         message "don't forget label"
  305.     } else {
  306.         message "type part name"
  307.     }
  308. }
  309. proc chapter {} {
  310.     if {[wrapObject "\\chapter{" "}•"]} then {
  311.         message "don't forget label"
  312.     } else {
  313.         message "type part name"
  314.     }
  315. }
  316. proc section {} {
  317.     if {[wrapObject "\\section{" "}•"]} then {
  318.         message "don't forget label"
  319.     } else {
  320.         message "type part name"
  321.     }
  322. }
  323. proc subsection {} {
  324.     if {[wrapObject "\\subsection{" "}•"]} then {
  325.         message "don't forget label"
  326.     } else {
  327.         message "type part name"
  328.     }
  329. }
  330. proc subsubsection {} {
  331.     if {[wrapObject "\\subsubsection{" "}•"]} then {
  332.         message "don't forget label"
  333.     } else {
  334.         message "type part name"
  335.     }
  336. }
  337. proc paragraph {} {
  338.     if {[wrapObject "\\paragraph{" "}•"]} then {
  339.         message "don't forget label"
  340.     } else {
  341.         message "type part name"
  342.     }
  343. }
  344. proc subparagraph {} {
  345.     if {[wrapObject "\\subparagraph{" "}•"]} then {
  346.         message "don't forget label"
  347.     } else {
  348.         message "type part name"
  349.     }
  350. }
  351.  
  352. # Definitions:
  353. proc myList {} {alertnote "Not yet implemented."}
  354. proc newcommand {} {alertnote "Not yet implemented."}
  355. proc newenvironment {} {alertnote "Not yet implemented."}
  356. proc newtheorem {} {alertnote "Not yet implemented."}
  357. proc renewcommand {} {alertnote "Not yet implemented."}
  358. proc renewenvironment {} {alertnote "Not yet implemented."}
  359.  
  360. # Text Style:
  361. proc roman {} {
  362.     if {[wrapObject "{\\rm " "}•"]} then {
  363.         message "roman text set"
  364.     } else {
  365.         message "enter roman text"
  366.     }
  367. }
  368. proc bold {} {
  369.     if {[wrapObject "{\\bf " "}•"]} then {
  370.         message "bold text set"
  371.     } else {
  372.         message "enter bold text"
  373.     }
  374. }
  375. proc italic {} {
  376.     if {[wrapObject "{\\it " "\/}•"]} then {
  377.         insertText "•"
  378.         backwardChar
  379.         backwardChar
  380.         backwardCharSelect
  381.         backwardCharSelect
  382.     } else {
  383.         forwardCharSelect
  384.         forwardCharSelect
  385.     }
  386.     message "italic correction?"
  387. }
  388. proc emphatic {} {
  389.     if {[wrapObject "{\\em " "\/}•"]} then {
  390.         insertText "•"
  391.         backwardChar
  392.         backwardChar
  393.         backwardCharSelect
  394.         backwardCharSelect
  395.     } else {
  396.         forwardCharSelect
  397.         forwardCharSelect
  398.     }
  399.     message "italic correction?"
  400. }
  401. proc slanted {} {
  402.     if {[wrapObject "{\\sl " "\/}•"]} then {
  403.         insertText "•"
  404.         backwardChar
  405.         backwardChar
  406.         backwardCharSelect
  407.         backwardCharSelect
  408.     } else {
  409.         forwardCharSelect
  410.         forwardCharSelect
  411.     }
  412.     message "italic correction?"
  413. }
  414. proc sansSerif {} {
  415.     if {[wrapObject "{\\sf " "}•"]} then {
  416.         message "sans serif text set"
  417.     } else {
  418.         message "enter sans serif text"
  419.     }
  420. }
  421. proc smallCaps {} {
  422.     if {[wrapObject "{\\sc " "}•"]} then {
  423.         message "small caps text set"
  424.     } else {
  425.         message "enter small caps text"
  426.     }
  427. }
  428. proc typewriter {} {
  429.     if {[wrapObject "{\\tt " "}•"]} then {
  430.         message "typewriter text set"
  431.     } else {
  432.         message "enter typewriter text"
  433.     }
  434. }
  435.  
  436. # Text Size:
  437. proc tiny {} {
  438.     if {[wrapObject "{\\tiny " "}•"]} then {
  439.         message "tiny text set"
  440.     } else {
  441.         message "enter tiny text"
  442.     }
  443. }
  444. proc smallest {} {
  445.     if {[wrapObject "{\\scriptsize " "}•"]} then {
  446.         message "scriptsize text set"
  447.     } else {
  448.         message "enter scriptsize text"
  449.     }
  450. }
  451. proc smaller {} {
  452.     if {[wrapObject "{\\footnotesize " "}•"]} then {
  453.         message "footnotesize text set"
  454.     } else {
  455.         message "enter footnotesize text"
  456.     }
  457. }
  458. proc small {} {
  459.     if {[wrapObject "{\\small " "}•"]} then {
  460.         message "small text set"
  461.     } else {
  462.         message "enter small text"
  463.     }
  464. }
  465. proc normal {} {
  466.     if {[wrapObject "{\\normalsize " "}•"]} then {
  467.         message "normalsize text set"
  468.     } else {
  469.         message "enter normalsize text"
  470.     }
  471. }
  472. proc large {} {
  473.     if {[wrapObject "{\\large " "}•"]} then {
  474.         message "large text set"
  475.     } else {
  476.         message "enter large text"
  477.     }
  478. }
  479. proc larger {} {
  480.     if {[wrapObject "{\\Large " "}•"]} then {
  481.         message "Large text set"
  482.     } else {
  483.         message "enter Large text"
  484.     }
  485. }
  486. proc largest {} {
  487.     if {[wrapObject "{\\LARGE " "}•"]} then {
  488.         message "LARGE text set"
  489.     } else {
  490.         message "enter LARGE text"
  491.     }
  492. }
  493. proc huge {} {
  494.     if {[wrapObject "{\\huge " "}•"]} then {
  495.         message "huge text set"
  496.     } else {
  497.         message "enter huge text"
  498.     }
  499. }
  500. proc gigantic {} {
  501.     if {[wrapObject "{\\Huge " "}•"]} then {
  502.         message "Huge text set"
  503.     } else {
  504.         message "enter Huge text"
  505.     }
  506. }
  507.  
  508. # International:  not yet implemented.
  509.  
  510. # Environments:
  511. proc enumerate {} {
  512.     catch {prompt "enumerate:  how many items?" 3} numberItems
  513.     if {$numberItems != "cancel"} then {
  514.         set currentPos [getPos]
  515.         if {[insertEnvironment "enumerate" 0]} then {
  516.             item
  517.             insertText "  •"
  518.             for {set i 1} {$i < $numberItems} {incr i} {
  519.                 carriageReturn
  520.                 carriageReturn
  521.                 item
  522.                 insertText "  •"
  523.             }
  524.             goto $currentPos
  525.             nextTabStop
  526.             message "Type first item"
  527.         }
  528.     }
  529. }
  530. proc itemize {} {
  531.     catch {prompt "itemize:  how many items?" 3} numberItems
  532.     if {$numberItems != "cancel"} then {
  533.         set currentPos [getPos]
  534.         if {[insertEnvironment "itemize" 0]} then {
  535.             item
  536.             insertText "  •"
  537.             for {set i 1} {$i < $numberItems} {incr i} {
  538.                 carriageReturn
  539.                 carriageReturn
  540.                 item
  541.                 insertText "  •"
  542.             }
  543.             goto $currentPos
  544.             nextTabStop
  545.             message "Type first item"
  546.         }
  547.     }
  548. }
  549. proc description {} {
  550.     catch {prompt "description: how many items?" 3} numberItems
  551.     if {$numberItems != "cancel"} then {
  552.         set currentPos [getPos]
  553.         if {[insertEnvironment "description" 0]} then {
  554.             item
  555.             insertText "\[•\]  •"
  556.             for {set i 1} {$i < $numberItems} {incr i} {
  557.                 carriageReturn
  558.                 carriageReturn
  559.                 item
  560.                 insertText "\[•\]  •"
  561.             }
  562.             goto $currentPos
  563.             nextTabStop
  564.             message "Type first item"
  565.         }
  566.     }
  567. }
  568.  
  569. proc insertRow {jmax} {
  570.     insertText "•"
  571.     for {set j 1} {$j < $jmax} {incr j} {
  572.         insertText " & •"
  573.     }
  574. }
  575. proc tabular {} {
  576.     catch {prompt "tabular:  how many rows?" 3} numberRows
  577.     if {$numberRows != "cancel"} then {
  578.         catch {prompt "tabular:  how many columns?" 3} numberCols
  579.         if {$numberCols != "cancel"} then {
  580.             if {[insertEnvironment "tabular" 1]} then {
  581.                 set beginArgument [getPos]
  582.                 insertText "|"
  583.                 for {set j 1} {$j <= $numberCols} {incr j} {
  584.                     insertText "c|"
  585.                 }
  586.                 set endArgument [getPos]
  587.                 nextTabStop
  588.                 insertText "\\hline"
  589.                 for {set i 1} {$i <= $numberRows} {incr i} {
  590.                     carriageReturn
  591.                     insertRow $numberCols
  592.                     insertText "  \\\\"
  593.                     carriageReturn
  594.                     insertText "\\hline"
  595.                 }
  596.                 goto $beginArgument
  597.                 setMark
  598.                 goto $endArgument
  599.                 markHilite
  600.                 message "modify argument?"
  601.             }
  602.         }
  603.     }
  604. }
  605. proc tabbing {} {alertnote "Not yet implemented."}
  606.  
  607. proc figure {} {
  608.     global useBoxMacro
  609.     global boxMacroName
  610.     if {$useBoxMacro} then {
  611.         set currentPos [getPos]
  612.         if {[insertEnvironment "figure" 0]} then {
  613.             insertText "\\centerline{\\$boxMacroName{•}}"
  614.         } else {
  615.             return
  616.         }
  617.     } else {
  618.         if {[wrapEnvironment "figure" 0]} then {
  619.             forwardChar
  620.             backwardChar
  621.             set currentPos [getPos]
  622.         } else {
  623.             set currentPos [getPos]
  624.             insertText "•"
  625.         }
  626.     }
  627.     carriageReturn
  628.     insertText "\\caption{•}"
  629.     carriageReturn
  630.     insertText "\\protect\\label{•}"
  631.     goto $currentPos
  632.     nextTabStop
  633. }
  634. proc table {} {
  635.     if {[wrapEnvironment "table" 0]} then {
  636.         forwardChar
  637.         backwardChar
  638.         set currentPos [getPos]
  639.     } else {
  640.         set currentPos [getPos]
  641.         insertText "•"
  642.     }
  643.     carriageReturn
  644.     insertText "\\caption{•}"
  645.     carriageReturn
  646.     insertText "\\protect\\label{•}"
  647.     goto $currentPos
  648.     nextTabStop
  649. }
  650. proc slide {} {
  651.     wrapEnvironment "slide" 1
  652.     message "enter colors"
  653. }
  654.  
  655. proc verbatim {} {wrapEnvironment "verbatim" 0}
  656. proc quote {} {wrapEnvironment "quote" 0}
  657. proc quotation {} {wrapEnvironment "quotation" 0}
  658. proc verse {} {wrapEnvironment "verse" 0}
  659.  
  660. proc index {} {alertnote "Not yet implemented."}
  661. proc bibliography {} {
  662.     catch {prompt "bibliography:  how many bibitems?" 3} numberItems
  663.     if {$numberItems != "cancel"} then {
  664.         if {[insertEnvironment "thebibliography" 1]} then {
  665.             set beginArgument [getPos]
  666.             insertText "99"
  667.             set endArgument [getPos]
  668.             nextTabStop
  669.             insertText "\\bibitem{•}"
  670.             carriageReturn
  671.             insertText "•"
  672.             for {set i 1} {$i < $numberItems} {incr i} {
  673.                 carriageReturn
  674.                 carriageReturn
  675.                 insertText "\\bibitem{•}"
  676.                 carriageReturn
  677.                 insertText "•"
  678.             }
  679.             goto $beginArgument
  680.             setMark
  681.             goto $endArgument
  682.             markHilite
  683.             message "modify argument?"
  684.         }
  685.     }
  686. }
  687.  
  688. proc general {} {
  689.     catch {prompt "What environment?" "center"} environmentName
  690.     if {$environmentName != "cancel"} {wrapEnvironment $environmentName 0}
  691. }
  692.  
  693. # Boxes:
  694. proc mbox {} {
  695.     if {[wrapObject "\\mbox{" "}•"]} then {
  696.         message "mbox set"
  697.     } else {
  698.         message "enter text"
  699.     }
  700. }
  701. proc fbox {} {alertnote "Not yet implemented."}
  702. proc parbox {} {alertnote "Not yet implemented."}
  703.  
  704. # Misc:
  705. proc ellipsis {} {insertObject "\\ldots"}
  706. proc sectionMark {} {insertObject "\\S"}
  707. proc paragraphMark {} {insertObject "\\P"}
  708. proc dagger {} {insertObject "\\dag"}
  709. proc dblDagger {} {insertObject "\\ddag"}
  710. proc copyright {} {insertObject "\\copyright"}
  711. proc pounds {} {insertObject "\\pounds"}
  712. proc {en-dash} {} {insertObject "--"}
  713. proc {em-dash} {} {insertObject "---"}
  714. proc texLogo {} {insertObject "\\TeX"}
  715. proc latexLogo {} {insertObject "\\LaTeX"}
  716. proc today {} {insertObject "\\today"}
  717.  
  718. proc quotes {} {
  719.     if {[wrapObject "`" "'•"]} then {
  720.         message "text quoted"
  721.     } else {
  722.         message "enter text"
  723.     }
  724. }
  725. proc dblQuotes {} {
  726.     if {[wrapObject "``" "''•"]} then {
  727.         message "text double quoted"
  728.     } else {
  729.         message "enter text"
  730.     }
  731. }
  732. proc note {} {
  733.     if {[wrapObject "\\marginpar{" "}•"]} then {
  734.         message "marginal note set"
  735.     } else {
  736.         message "enter marginal note"
  737.     }
  738. }
  739. proc footnote {} {
  740.     if {[wrapObject "\\footnote{" "}•"]} then {
  741.         message "footnote set"
  742.     } else {
  743.         message "enter footnote"
  744.     }
  745. }
  746. proc label {} {
  747.     if {[wrapObject "\\label{" "}•"]} then {
  748.         message "label defined"
  749.     } else {
  750.         message "enter label"
  751.     }
  752. }
  753. proc crossRef {} { 
  754.     if {[wrapObject "\\ref{" "}•"]} then {
  755.         message "cross-reference made"
  756.     } else {
  757.         message "enter cross-reference"
  758.     }
  759. }
  760. proc pageRef {} { 
  761.     if {[wrapObject "\\pageref{" "}•"]} then {
  762.         message "page reference made"
  763.     } else {
  764.         message "enter page reference"
  765.     }
  766. }
  767. proc citation {} {
  768.     if {[wrapObject "\\cite{" "}•"]} then {
  769.         message "citation made"
  770.     } else {
  771.         message "enter citation"
  772.     }
  773. }
  774. proc item {} {insertObject "\\item"}
  775. proc bibitem {} {
  776.     if {[wrapObject "\\bibitem{" "}•"]} then {
  777.         message "bibitem set"
  778.     } else {
  779.         message "enter bibitem"
  780.     }
  781. }
  782.  
  783.  
  784. #############################################################################
  785. # Math Mode Macros.
  786. #
  787. #############################################################################
  788.  
  789. # Modes:
  790. proc texMath {} {
  791.     if {[wrapObject "$" "$•"]} then {
  792.         message "formula set"
  793.     } else {
  794.         message "enter formula"
  795.     }
  796. }
  797. proc texDisplaymath {} {
  798.     if {[wrapObject "$$" "$$•"]} then {
  799.         message "displayed formula set"
  800.     } else {
  801.         message "enter displayed formula"
  802.     }
  803. }
  804. proc latexMath {} {
  805.     if {[wrapObject "\\( " " \\)•"]} then {
  806.         message "formula set"
  807.     } else {
  808.         message "enter formula"
  809.     }
  810. }
  811. proc latexDisplaymath {} {
  812.     if {[wrapObject "\\\[ " " \\\]•"]} then {
  813.         message "displayed formula set"
  814.     } else {
  815.         message "enter displayed formula"
  816.     }
  817. }
  818.  
  819. # Environments:
  820. proc math {} {wrapEnvironment "math" 0}
  821. proc displaymath {} {wrapEnvironment "displaymath" 0}
  822. proc equation {} {
  823.     if {[wrapEnvironment "equation" 0]} then {
  824.         forwardChar
  825.         backwardChar
  826.         set currentPos [getPos]
  827.     } else {
  828.         set currentPos [getPos]
  829.         insertText "•"
  830.     }
  831.     carriageReturn
  832.     insertText "\\label{•}"
  833.     goto $currentPos
  834.     nextTabStop
  835. }
  836. proc myArray {} {
  837.     catch {prompt "array:  how many rows?" 3} numberRows
  838.     if {$numberRows != "cancel"} then {
  839.         catch {prompt "array:  how many columns?" 3} numberCols
  840.         if {$numberCols != "cancel"} then {
  841.             if {[insertEnvironment "array" 1]} then {
  842.                 set beginArgument [getPos]
  843.                 for {set j 1} {$j <= $numberCols} {incr j} {
  844.                     insertText "c"
  845.                 }
  846.                 set endArgument [getPos]
  847.                 nextTabStop
  848.                 for {set i 1} {$i < $numberRows} {incr i} {
  849.                     insertRow $numberCols
  850.                     insertText "  \\\\"
  851.                     carriageReturn
  852.                 }
  853.                 insertRow $numberCols
  854.                 goto $beginArgument
  855.                 setMark
  856.                 goto $endArgument
  857.                 markHilite
  858.                 message "modify argument?"
  859.             }
  860.         }
  861.     }
  862. }
  863. proc eqnarray {} {
  864.     catch {prompt "eqnarray:  how many rows?" 3} numberRows
  865.     if {$numberRows != "cancel"} then {
  866.         set currentPos [getPos]
  867.         if {[insertEnvironment "eqnarray" 0]} then {
  868.             for {set i 1} {$i < $numberRows} {incr i} {
  869.                 insertRow 3
  870.                 carriageReturn
  871.                 insertText "\\label{•} \\\\"
  872.                 carriageReturn
  873.             }
  874.             insertRow 3
  875.             carriageReturn
  876.             insertText "\\label{•}"
  877.             goto $currentPos
  878.             nextTabStop
  879.         }
  880.     }
  881. }
  882. proc eqnarrayStar {} {
  883.     catch {prompt "eqnarray*:  how many rows?" 3} numberRows
  884.     if {$numberRows != "cancel"} then {
  885.         set currentPos [getPos]
  886.         if {[insertEnvironment "eqnarray*" 0]} then {
  887.             for {set i 1} {$i < $numberRows} {incr i} {
  888.                 insertRow 3
  889.                 insertText "  \\\\"
  890.                 carriageReturn
  891.             }
  892.             insertRow 3
  893.             goto $currentPos
  894.             nextTabStop
  895.         }
  896.     }
  897. }
  898.  
  899. # Formulas:
  900. proc subscript {} {
  901.     if {[wrapObject "_{" "}•"]} then {
  902.         message "subscript set"
  903.     } else {
  904.         message "enter subscript"
  905.     }
  906. }
  907. proc superscript {} {
  908.     if {[wrapObject "^{" "}•"]} then {
  909.         message "superscript set"
  910.     } else {
  911.         message "enter superscript"
  912.     }
  913. }
  914. proc fraction {} {
  915.     set currentPos [getPos]
  916.     if {[isSelection]} then {
  917.         set selection [getSelect]
  918.         set args [split $selection /]
  919.         set len [llength $args]
  920.         deleteText $currentPos [selEnd]
  921.         if {$len == 1} then {
  922.             # maybe the selection should be deleted in this case?
  923.             insertText "\\frac{" $selection "}{•}•"
  924.             goto $currentPos
  925.             nextTabStop
  926.             message "enter denominator"
  927.         } else {
  928.             set firstArg [lindex $args 0]
  929.             set restArgs [lrange $args 1 [expr $len-1]]
  930.             insertText "\\frac{" $firstArg "}{" [join $restArgs /] "}"
  931.             if {$len > 2} {message "beware of multiple /"}
  932.         }
  933.     } else {
  934.         insertText "\\frac{•}{•}•"
  935.         goto $currentPos
  936.         nextTabStop
  937.         message "enter numerator"
  938.     }
  939. }
  940. proc squareRoot {} {
  941.     if {[wrapObject "\\sqrt{" "}•"]} then {
  942.         message "square root set"
  943.     } else {
  944.         message "enter formula"
  945.     }
  946. }
  947. proc nthRoot {} {
  948.     if {[wrapObject "\\sqrt\[•\]{" "}•"]} then {
  949.         message "enter root"
  950.     } else {
  951.         message "enter root, then formula"
  952.     }
  953. }
  954. proc oneParameter {} {
  955.     catch {prompt "Command name?" "sqrt"} commandName
  956.     if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}•"}
  957. }
  958. proc twoParameters {} {
  959.     catch {prompt "Command name?" "frac"} commandName
  960.     if {$commandName != "cancel"} then {
  961.         set currentPos [getPos]
  962.         if {[insertObject "\\$commandName{•}{•}•"]} then {
  963.             goto $currentPos
  964.             nextTabStop
  965.         }
  966.     }
  967. }
  968.  
  969. # Greek:
  970. proc alpha {} {insertObject "\\alpha"}
  971. proc beta {} {insertObject "\\beta"}
  972. proc gamma {} {insertObject "\\gamma"}
  973. proc delta {} {insertObject "\\delta"}
  974. proc epsilon {} {insertObject "\\epsilon"}
  975. proc zeta {} {insertObject "\\zeta"}
  976. proc eta {} {insertObject "\\eta"}
  977. proc theta {} {insertObject "\\theta"}
  978. proc iota {} {insertObject "\\iota"}
  979. proc kappa {} {insertObject "\\kappa"}
  980. proc lambda {} {insertObject "\\lambda"}
  981. proc mu {} {insertObject "\\mu"}
  982. proc nu {} {insertObject "\\nu"}
  983. proc xi {} {insertObject "\\xi"}
  984. proc pi {} {insertObject "\\pi"}
  985. proc rho {} {insertObject "\\rho"}
  986. proc sigma {} {insertObject "\\sigma"}
  987. proc tau {} {insertObject "\\tau"}
  988. proc upsilon {} {insertObject "\\upsilon"}
  989. proc phi {} {insertObject "\\phi"}
  990. proc chi {} {insertObject "\\chi"}
  991. proc psi {} {insertObject "\\psi"}
  992. proc omega {} {insertObject "\\omega"}
  993.  
  994. proc capGamma {} {insertObject "\\Gamma"}
  995. proc capDelta {} {insertObject "\\Delta"}
  996. proc capTheta {} {insertObject "\\Theta"}
  997. proc capLambda {} {insertObject "\\Lambda"}
  998. proc capXi {} {insertObject "\\Xi"}
  999. proc capPi {} {insertObject "\\Pi"}
  1000. proc capSigma {} {insertObject "\\Sigma"}
  1001. proc capUpsilon {} {insertObject "\\Upsilon"}
  1002. proc capPhi {} {insertObject "\\Phi"}
  1003. proc capPsi {} {insertObject "\\Psi"}
  1004. proc capOmega {} {insertObject "\\Omega"}
  1005.  
  1006. proc varEpsilon {} {insertObject "\\varepsilon"}
  1007. proc varTheta {} {insertObject "\\vartheta"}
  1008. proc varPi {} {insertObject "\\varpi"}
  1009. proc varRho {} {insertObject "\\varrho"}
  1010. proc varSigma {} {insertObject "\\varsigma"}
  1011. proc varPhi {} {insertObject "\\varphi"}
  1012.  
  1013. # Binary Ops:
  1014. proc plusOrMinus {} {insertObject "\\pm"}
  1015. proc minusOrPlus {} {insertObject "\\mp"}
  1016. proc multiply {} {insertObject "\\times"}
  1017. proc divide {} {insertObject "\\div"}
  1018. proc asterisk {} {insertObject "\\ast"}
  1019. proc star {} {insertObject "\\star"}
  1020. proc circle {} {insertObject "\\circ"}
  1021. proc bigCircle {} {insertObject "\\bigcirc"}
  1022. proc bullet {} {insertObject "\\bullet"}
  1023. proc centerDot {} {insertObject "\\cdot"}
  1024. proc intersection {} {insertObject "\\cap"}
  1025. proc union {} {insertObject "\\cup"}
  1026. proc logicalAnd {} {insertObject "\\wedge"}
  1027. proc logicalOr {} {insertObject "\\vee"}
  1028. proc setMinus {} {insertObject "\\setminus"}
  1029.  
  1030. # Relations:
  1031. proc notEqual {} {insertObject "\\neq"}
  1032. proc lessOrEqual {} {insertObject "\\leq"}
  1033. proc greaterOrEqual {} {insertObject "\\geq"}
  1034. proc subset {} {insertObject "\\subset"}
  1035. proc superset {} {insertObject "\\supset"}
  1036. proc subsetOrEqual {} {insertObject "\\subseteq"}
  1037. proc supersetOrEqual {} {insertObject "\\supseteq"}
  1038. proc elementOf {} {insertObject "\\in"}
  1039. proc equivalent {} {insertObject "\\equiv"}
  1040. proc similar {} {insertObject "\\sim"}
  1041. proc similarEqual {} {insertObject "\\simeq"}
  1042. proc dotEqual {} {insertObject "\\doteq"}
  1043. proc approximate {} {insertObject "\\approx"}
  1044. proc congruent {} {insertObject "\\cong"}
  1045.  
  1046. # Large Ops:
  1047. proc insertLargeOp {commandName} {
  1048.     set currentPos [getPos]
  1049.     insertText "\\$commandName"
  1050.     insertText "_{•}^{•}•"
  1051.     goto $currentPos
  1052.     nextTabStop
  1053. }
  1054. proc sum {} {insertLargeOp "sum"}
  1055. proc product {} {insertLargeOp "prod"}
  1056. proc integral {} {insertLargeOp "int"}
  1057. proc bigUnion {} {insertLargeOp "bigcup"}
  1058. proc bigIntersection {} {insertLargeOp "bigcap"}
  1059. proc bigAnd {} {insertLargeOp "bigwedge"}
  1060. proc bigOr {} {insertLargeOp "bigvee"}
  1061.  
  1062. # Arrows:
  1063. proc mapsTo {} {insertObject "\\mapsto"}
  1064. proc leftArrow {} {insertObject "\\leftarrow"}
  1065. proc rightArrow {} {insertObject "\\rightarrow"}
  1066. proc {left-rightArrow} {} {insertObject "\\leftrightarrow"}
  1067. proc dblLeftArrow {} {insertObject "\\Leftarrow"}
  1068. proc dblRightArrow {} {insertObject "\\Rightarrow"}
  1069. proc {dblLeft-rightArrow} {} {insertObject "\\Leftrightarrow"}
  1070.  
  1071. # Dots:
  1072. proc centerDots {} {insertObject "\\cdots"}
  1073. proc verticalDots {} {insertObject "\\vdots"}
  1074. proc diagonalDots {} {insertObject "\\ddots"}
  1075.  
  1076. # Symbols:
  1077. proc aleph {} {insertObject "\\aleph"}
  1078. proc emptySet {} {insertObject "\\emptyset"}
  1079. proc negation {} {insertObject "\\neg"}
  1080. proc forAll {} {insertObject "\\forall"}
  1081. proc exists {} {insertObject "\\exists"}
  1082. proc scriptL {} {insertObject "\\ell"}
  1083. proc nabla {} {insertObject "\\nabla"}
  1084. proc partial {} {insertObject "\\partial"}
  1085. proc infinity {} {insertObject "\\infty"}
  1086. proc backslash {} {insertObject "\\backslash"}
  1087. proc angle {} {insertObject "\\angle"}
  1088. proc box {} {insertObject "\\Box"}
  1089. proc diamond {} {insertObject "\\Diamond"}
  1090. proc triangle {} {insertObject "\\triangle"}
  1091.  
  1092. # Functions:  not yet implemented.
  1093.  
  1094. # Delimiters:
  1095. proc parentheses {} {
  1096.     if {[wrapObject "(" ")•"]} then {
  1097.         message "formula delimited"
  1098.     } else {
  1099.         message "enter formula"
  1100.     }
  1101. }
  1102. proc brackets {} {
  1103.     if {[wrapObject "\[" "\]•"]} then {
  1104.         message "formula delimited"
  1105.     } else {
  1106.         message "enter formula"
  1107.     }
  1108. }
  1109. proc braces {} {
  1110.     if {[wrapObject "\\\{" "\\\}•"]} then {
  1111.         message "formula delimited"
  1112.     } else {
  1113.         message "enter formula"
  1114.     }
  1115. }
  1116. proc absoluteValue {} {
  1117.     if {[wrapObject "|" "|•"]} then {
  1118.         message "formula delimited"
  1119.     } else {
  1120.         message "enter formula"
  1121.     }
  1122. }
  1123. proc otherDelims {} {
  1124.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" "braces" "angle brackets" "vertical bars" "double bars" "ceiling" "floor"} delimType
  1125.     if {$delimType != "cancel"} then {
  1126.         case $delimType in {
  1127.             "parentheses" {
  1128.                 set leftDelim "("
  1129.                 set rightDelim ")"
  1130.             }
  1131.             "brackets" {
  1132.                 set leftDelim "\["
  1133.                 set rightDelim "\]"
  1134.             }
  1135.             "braces" {
  1136.                 set leftDelim "\\\{"
  1137.                 set rightDelim "\\\}"
  1138.             }
  1139.             "{angle brackets}" {
  1140.                 set leftDelim "\\langle"
  1141.                 set rightDelim "\\rangle"
  1142.             }
  1143.             "{vertical bars}" {
  1144.                 set leftDelim "|"
  1145.                 set rightDelim "|"
  1146.             }
  1147.             "{double bars}" {
  1148.                 set leftDelim "\\|"
  1149.                 set rightDelim "\\|"
  1150.             }
  1151.             "ceiling" {
  1152.                 set leftDelim "\\lceil"
  1153.                 set rightDelim "\\rceil"
  1154.             }
  1155.             "floor" {
  1156.                 set leftDelim "\\lfloor"
  1157.                 set rightDelim "\\rfloor"
  1158.             }
  1159.             default {
  1160.                 alertnote "\"$delimType\" not recognized"
  1161.                 return
  1162.             }
  1163.         }
  1164.         if {[wrapObject "$leftDelim" "$rightDelim•"]} then {
  1165.             message "formula delimited"
  1166.         } else {
  1167.             message "enter formula"
  1168.         }
  1169.     }
  1170. }
  1171.  
  1172. proc {half-openInterval} {} {
  1173.     if {[wrapObject "(" "\]•"]} then {
  1174.         message "formula delimited"
  1175.     } else {
  1176.         message "enter formula"
  1177.     }
  1178. }
  1179. proc {half-closedInterval} {} {
  1180.     if {[wrapObject "\[" ")•"]} then {
  1181.         message "formula delimited"
  1182.     } else {
  1183.         message "enter formula"
  1184.     }
  1185. }
  1186.  
  1187. proc bigParentheses {} {
  1188.     if {[wrapObject "\\left(" "\\right)•"]} then {
  1189.         message "formula delimited"
  1190.     } else {
  1191.         message "enter formula"
  1192.     }
  1193. }
  1194. proc bigBrackets {} {
  1195.     if {[wrapObject "\\left\[" "\\right\]•"]} then {
  1196.         message "formula delimited"
  1197.     } else {
  1198.         message "enter formula"
  1199.     }
  1200. }
  1201. proc bigBraces {} {
  1202.     if {[wrapObject "\\left\\\{" "\\right\\\}•"]} then {
  1203.         message "formula delimited"
  1204.     } else {
  1205.         message "enter formula"
  1206.     }
  1207. }
  1208. proc bigAbsoluteValue {} {
  1209.     if {[wrapObject "\\left|" "\\right|•"]} then {
  1210.         message "formula delimited"
  1211.     } else {
  1212.         message "enter formula"
  1213.     }
  1214. }
  1215. proc otherBigDelims {} {
  1216.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" \
  1217.                 "braces" "angle brackets" "vertical bars" "double bars" \
  1218.                 "ceiling" "floor"} delimType
  1219.     if {$delimType != "cancel"} then {
  1220.         case $delimType in {
  1221.             "parentheses" {
  1222.                 set leftDelim "("
  1223.                 set rightDelim ")"
  1224.             }
  1225.             "brackets" {
  1226.                 set leftDelim "\["
  1227.                 set rightDelim "\]"
  1228.             }
  1229.             "braces" {
  1230.                 set leftDelim "\\\{"
  1231.                 set rightDelim "\\\}"
  1232.             }
  1233.             "{angle brackets}" {
  1234.                 set leftDelim "\\langle"
  1235.                 set rightDelim "\\rangle"
  1236.             }
  1237.             "{vertical bars}" {
  1238.                 set leftDelim "|"
  1239.                 set rightDelim "|"
  1240.             }
  1241.             "{double bars}" {
  1242.                 set leftDelim "\\|"
  1243.                 set rightDelim "\\|"
  1244.             }
  1245.             "ceiling" {
  1246.                 set leftDelim "\\lceil"
  1247.                 set rightDelim "\\rceil"
  1248.             }
  1249.             "floor" {
  1250.                 set leftDelim "\\lfloor"
  1251.                 set rightDelim "\\rfloor"
  1252.             }
  1253.             default {
  1254.                 alertnote "\"$delimType\" not recognized"
  1255.                 return
  1256.             }
  1257.         }
  1258.         if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1259.             message "formula delimited"
  1260.         } else {
  1261.             message "enter formula"
  1262.         }
  1263.     }
  1264. }
  1265.  
  1266. proc bigLeftBrace {} {
  1267.     if {[wrapObject "\\left\\\{" "\\right.•"]} then {
  1268.         message "formula delimited"
  1269.     } else {
  1270.         message "enter formula"
  1271.     }
  1272. }
  1273. proc otherMixedBigDelims {} {
  1274.     catch {prompt "Choose left delimiter:" "parenthesis" "" "parenthesis" "bracket" \
  1275.              "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor"  \
  1276.              "slash" "backslash" "none"} delimType
  1277.     if {$delimType != "cancel"} then {
  1278.         case $delimType in {
  1279.             "parenthesis" {set leftDelim "("}
  1280.             "bracket" {set leftDelim "\["}
  1281.             "brace" {set leftDelim "\\\{"}
  1282.             "{angle bracket}" {set leftDelim "\\langle"}
  1283.             "{vertical bar}" {set leftDelim "|"}
  1284.             "{double bar}" {set leftDelim "\\|"}
  1285.             "ceiling" {set leftDelim "\\lceil"}
  1286.             "floor" {set leftDelim "\\lfloor"}
  1287.             "slash" {set leftDelim "/"}
  1288.             "backslash" {set leftDelim "\\backslash"}
  1289.             "none" {set leftDelim "."}
  1290.             default {
  1291.                 alertnote "\"$delimType\" not recognized"
  1292.                 return
  1293.             }
  1294.         }
  1295.         catch {prompt "Choose right delimiter:" "parenthesis" "" "parenthesis" "bracket" \
  1296.                 "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" \
  1297.                 "slash" "backslash" "none"} delimType
  1298.         if {$delimType != "cancel"} then {
  1299.             case $delimType in {
  1300.                 "parenthesis" {set rightDelim ")"}
  1301.                 "bracket" {set rightDelim "\]"}
  1302.                 "brace" {set rightDelim "\\\}"}
  1303.                 "{angle bracket}" {set rightDelim "\\rangle"}
  1304.                 "{vertical bar}" {set rightDelim "|"}
  1305.                 "{double bar}" {set rightDelim "\\|"}
  1306.                 "ceiling" {set rightDelim "\\rceil"}
  1307.                 "floor" {set rightDelim "\\rfloor"}
  1308.                 "slash" {set rightDelim "/"}
  1309.                 "backslash" {set rightDelim "\\backslash"}
  1310.                 "none" {set rightDelim "."}
  1311.                 default {
  1312.                     alertnote "\"$delimType\" not recognized"
  1313.                     return
  1314.                 }
  1315.             }
  1316.             if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1317.                 message "formula delimited"
  1318.             } else {
  1319.                 message "enter formula"
  1320.             }
  1321.         }
  1322.     }
  1323. }
  1324.  
  1325. # Accents:
  1326. proc hat {} {
  1327.     if {[isSelection] > 1} then {
  1328.         beep
  1329.         alertnote "Warning: only a single character may be accented!"
  1330.     }
  1331.     if {[wrapObject "\\hat{" "}•"]} then {
  1332.         message "accent set"
  1333.     } else {
  1334.         message "enter one character"
  1335.     }
  1336. }
  1337. proc check {} {
  1338.     if {[isSelection] > 1} then {
  1339.         beep
  1340.         alertnote "Warning: only a single character may be accented!"
  1341.     }
  1342.     if {[wrapObject "\\check{" "}•"]} then {
  1343.         message "accent set"
  1344.     } else {
  1345.         message "enter one character"
  1346.     }
  1347. }
  1348. proc breve {} {
  1349.     if {[isSelection] > 1} then {
  1350.         beep
  1351.         alertnote "Warning: only a single character may be accented!"
  1352.     }
  1353.     if {[wrapObject "\\breve{" "}•"]} then {
  1354.         message "accent set"
  1355.     } else {
  1356.         message "enter one character"
  1357.     }
  1358. }
  1359. proc acuteAccent {} {
  1360.     if {[isSelection] > 1} then {
  1361.         beep
  1362.         alertnote "Warning: only a single character may be accented!"
  1363.     }
  1364.     if {[wrapObject "\\acute{" "}•"]} then {
  1365.         message "accent set"
  1366.     } else {
  1367.         message "enter one character"
  1368.     }
  1369. }
  1370. proc graveAccent {} {
  1371.     if {[isSelection] > 1} then {
  1372.         beep
  1373.         alertnote "Warning: only a single character may be accented!"
  1374.     }
  1375.     if {[wrapObject "\\grave{" "}•"]} then {
  1376.         message "accent set"
  1377.     } else {
  1378.         message "enter one character"
  1379.     }
  1380. }
  1381. proc tilde {} {
  1382.     if {[isSelection] > 1} then {
  1383.         beep
  1384.         alertnote "Warning: only a single character may be accented!"
  1385.     }
  1386.     if {[wrapObject "\\tilde{" "}•"]} then {
  1387.         message "accent set"
  1388.     } else {
  1389.         message "enter one character"
  1390.     }
  1391. }
  1392. proc bar {} {
  1393.     if {[isSelection] > 1} then {
  1394.         beep
  1395.         alertnote "Warning: only a single character may be accented!"
  1396.     }
  1397.     if {[wrapObject "\\bar{" "}•"]} then {
  1398.         message "accent set"
  1399.     } else {
  1400.         message "enter one character"
  1401.     }
  1402. }
  1403. proc vector {} {
  1404.     if {[isSelection] > 1} then {
  1405.         beep
  1406.         alertnote "Warning: only a single character may be accented!"
  1407.     }
  1408.     if {[wrapObject "\\vec{" "}•"]} then {
  1409.         message "accent set"
  1410.     } else {
  1411.         message "enter one character"
  1412.     }
  1413. }
  1414. proc dot {} {
  1415.     if {[isSelection] > 1} then {
  1416.         beep
  1417.         alertnote "Warning: only a single character may be accented!"
  1418.     }
  1419.     if {[wrapObject "\\dot{" "}•"]} then {
  1420.         message "accent set"
  1421.     } else {
  1422.         message "enter one character"
  1423.     }
  1424. }
  1425. proc dblDot {} {
  1426.     if {[isSelection] > 1} then {
  1427.         beep
  1428.         alertnote "Warning: only a single character may be accented!"
  1429.     }
  1430.     if {[wrapObject "\\ddot{" "}•"]} then {
  1431.         message "accent set"
  1432.     } else {
  1433.         message "enter one character"
  1434.     }
  1435. }
  1436.  
  1437. proc wideHat {} {
  1438.     if {[isSelection] > 3} then {
  1439.         beep
  1440.         alertnote "Warning: only a few characters may be accented!"
  1441.     }
  1442.     if {[wrapObject "\\widehat{" "}•"]} then {
  1443.         message "accent set"
  1444.     } else {
  1445.         message "enter a few characters"
  1446.     }
  1447. }
  1448. proc wideTilde {} {
  1449.     if {[isSelection] > 3} then {
  1450.         beep
  1451.         alertnote "Warning: only a few characters may be accented!"
  1452.     }
  1453.     if {[wrapObject "\\widetilde{" "}•"]} then {
  1454.         message "accent set"
  1455.     } else {
  1456.         message "enter a few characters"
  1457.     }
  1458. }
  1459.  
  1460. proc dotlessI {} {insertObject "\\imath"}
  1461. proc dotlessJ {} {insertObject "\\jmath"}
  1462.  
  1463. # Grouping:
  1464. proc underline {} {
  1465.     if {[wrapObject "\\underline{" "}•"]} then {
  1466.         message "selection underlined"
  1467.     } else {
  1468.         message "enter text"
  1469.     }
  1470. }
  1471. proc overline {} {
  1472.     if {[wrapObject "\\overline{" "}•"]} then {
  1473.         message "selection overlined"
  1474.     } else {
  1475.         message "enter text"
  1476.     }
  1477. }
  1478. proc underbrace {} {
  1479.     if {[wrapObject "\\underbrace{" "}•"]} then {
  1480.         message "selection underbraced"
  1481.     } else {
  1482.         message "enter text"
  1483.     }
  1484. }
  1485. proc overbrace {} {
  1486.     if {[wrapObject "\\overbrace{" "}•"]} then {
  1487.         message "selection overbraced"
  1488.     } else {
  1489.         message "enter text"
  1490.     }
  1491. }
  1492. proc stack {} {
  1493.     set currentPos [getPos]
  1494.     if {[insertObject "\\stackrel{•}{•}•"]} then {
  1495.         goto $currentPos
  1496.         nextTabStop
  1497.         message "1st arg scriptstyle"
  1498.     }
  1499. }
  1500.  
  1501. # Spacing:
  1502. proc thin {} {insertObject "\\,"}
  1503. proc negThin {} {insertObject "\\!"}
  1504. proc medium {} {insertObject "\\:"}
  1505. proc thick {} {insertObject "\\;"}
  1506. proc quad {} {insertObject "\\quad"}
  1507. proc dblQuad {} {insertObject "\\qquad"}
  1508.  
  1509. # Math Style:
  1510. proc mathItalic {} {
  1511.     if {[wrapObject "{\\mit " "}•"]} then {
  1512.         message "math italics set"
  1513.     } else {
  1514.         message "enter italicized text"
  1515.     }
  1516. }
  1517. proc calligraphic {} {
  1518.     # Check for upper-case arguments only:
  1519.     if {[wrapObject "{\\cal " "}•"]} then {
  1520.         message "calligraphics set"
  1521.     } else {
  1522.         message "enter text"
  1523.     }
  1524. }
  1525. proc fraktur {} {
  1526.     alertnote "Not yet implemented."
  1527. }
  1528. proc script {} {
  1529.     alertnote "Not yet implemented."
  1530. }
  1531. proc blackboardBold {} {
  1532.     alertnote "Not yet implemented."
  1533. }
  1534. proc displayStyle {} {
  1535.     if {[wrapObject "{\\displaystyle " "}•"]} then {
  1536.         message "displaystyle set"
  1537.     } else {
  1538.         message "enter displaystyle text"
  1539.     }
  1540. }
  1541. proc textStyle {} {
  1542.     if {[wrapObject "{\\textstyle " "}•"]} then {
  1543.         message "textstyle set"
  1544.     } else {
  1545.         message "enter textstyle text"
  1546.     }
  1547. }
  1548. proc scriptStyle {} {
  1549.     if {[wrapObject "{\\scriptstyle " "}•"]} then {
  1550.         message "scriptstyle set"
  1551.     } else {
  1552.         message "enter scriptstyle text"
  1553.     }
  1554. }
  1555. proc scriptscriptStyle {} {
  1556.     if {[wrapObject "{\\scriptscriptstyle " "}•"]} then {
  1557.         message "scriptscriptstyle set"
  1558.     } else {
  1559.         message "enter scriptscriptstyle text"
  1560.     }
  1561. }
  1562.  
  1563.  
  1564. #############################################################################
  1565. #
  1566. # LaTeX Menu Definition.
  1567. #
  1568. #############################################################################
  1569.  
  1570. proc interpretMenuItem {menu item} {
  1571.     case $item in {
  1572.         "list" {set func "myList"}
  1573.         "array" {set func "myArray"}
  1574.         "eqnarray\*" {set func "eqnarrayStar"}
  1575.         default {set func $item}
  1576.     }
  1577.     eval $func
  1578. }
  1579.  
  1580. # LaTeX mode
  1581. proc setTexMode {} {
  1582.     global latexMenu excaliburMenu
  1583.     changeMode "Tex"
  1584.     removeMenu $excaliburMenu
  1585.     uplevel #0 {    
  1586.         set wordBreakPreface {[^a-zA-Z0-9]}
  1587.         set wordBreak {[a-zA-Z0-9]+}
  1588.         set elecLBrace 0
  1589.         set elecRBrace 0
  1590.         set electricSemi 0
  1591.         set wordWrap 1
  1592.         set prefixString "% "
  1593.         set funcTitle "Sect"
  1594.         set sortedIsDefault 0
  1595.         set funcExpr {^\\(sub)*section\*?{([^{}]*)}}
  1596. #        set funcExpr {^\\(sub)*section\*?{(.*)}$}
  1597.         set funcPar 2
  1598.         set savedIsMeta $optionIsMeta
  1599. #    Uncomment next line to use option key in Tex bindings.
  1600. #        set optionIsMeta 0
  1601. #    Next is a call to a random proc in the latex file to make sure
  1602. #    is it auto-loaded.
  1603.         isSelection
  1604.         insertMenu $latexMenu
  1605.     }
  1606. }
  1607.  
  1608. #================================================================================
  1609. set latexMenu "•266"
  1610. proc latex {} {
  1611.     global latexPath
  1612.     set sig ""
  1613.     catch {string trim [lindex [getfinfo $latexPath] 1] '} sig
  1614.     set name [checkRunning latex $sig latexPath]
  1615.     if {![string length $name]} return
  1616.     switchTo $name
  1617.     catch {sendOpenEvent -n $name [lindex [winNames -f] 0]}
  1618. }
  1619.  
  1620. proc commentLine {} {
  1621.     beginningOfLine
  1622.     insertText "% "
  1623.     nextLine
  1624.     beginningOfLine
  1625. }
  1626.  
  1627. # Open file in same directory, expect name w/o extension selected.
  1628. proc openInputFile {} {
  1629.     set text [getSelect].tex
  1630.     if {[string length $text] < 5} { beep; return }
  1631.     foreach f [winNames] {
  1632.         if {$f == $text} {
  1633.             bringToFront $f
  1634.             return
  1635.         }
  1636.     }
  1637.     edit [file dirname [lindex [winNames -f] 0]]:$text
  1638. }
  1639.  
  1640.  
  1641. menu -n $latexMenu  {
  1642.     "/-latex"
  1643.     "spellcheckWindow"
  1644.     "openInputFile"
  1645.     "(-"
  1646.     {menu -n Documents -p interpretMenuItem {
  1647.         "letter"
  1648.         "article"
  1649.         "report"
  1650.         "book"
  1651.         "(-"
  1652.         "custom…"}
  1653.     }
  1654.     
  1655.     {menu -n Sectioning -p interpretMenuItem {
  1656.         "part"
  1657.         "chapter"
  1658.         "section"
  1659.         "subsection"
  1660.         "subsubsection"
  1661.         "paragraph"
  1662.         "subparagraph"}
  1663.     }
  1664.     
  1665.     {menu -n (Definitions -p interpretMenuItem {
  1666.         "list…"
  1667.         "(-"
  1668.         "newcommand…"
  1669.         "newenvironment…"
  1670.         "newtheorem…"
  1671.         "(-"
  1672.         "renewcommand…"
  1673.         "renewenvironment…"}
  1674.     }
  1675.     
  1676.     "(-"
  1677.     
  1678.     {menu -n TextStyle -p interpretMenuItem {
  1679.         "roman"
  1680.         "bold"
  1681.         "italic"
  1682.         "emphatic"
  1683.         "slanted"
  1684.         "sansSerif"
  1685.         "smallCaps"
  1686.         "typewriter"}
  1687.     }
  1688.     
  1689.     {menu -n TextSize -p interpretMenuItem {
  1690.         "tiny"
  1691.         "smallest"
  1692.         "smaller"
  1693.         "small"
  1694.         "normal"
  1695.         "large"
  1696.         "larger"
  1697.         "largest"
  1698.         "huge"
  1699.         "gigantic"}
  1700.     }
  1701.     
  1702.     {menu -n (International -p interpretMenuItem {
  1703.         }
  1704.     }
  1705.     
  1706.     {menu -n Environments -p interpretMenuItem {
  1707.         "enumerate…"
  1708.         "itemize…"
  1709.         "description…"
  1710.         "(-"
  1711.         "tabular…"
  1712.         "(tabbing"
  1713.         "(-"
  1714.         "figure"
  1715.         "table"
  1716.         "slide"
  1717.         "(-"
  1718.         "verbatim"
  1719.         "quote"
  1720.         "quotation"
  1721.         "verse"
  1722.         "(-"
  1723.         "(index…"
  1724.         "bibliography…"
  1725.         "(-"
  1726.         "general…"}
  1727.     }
  1728.     
  1729.     {menu -n Boxes -p interpretMenuItem {
  1730.         "mbox"
  1731.         "(fbox"
  1732.         "(parbox"}
  1733.     }
  1734.     
  1735.     {menu -n Miscellaneous -p interpretMenuItem {
  1736.         "ellipsis"
  1737.         "sectionMark"
  1738.         "paragraphMark"
  1739.         "dagger"
  1740.         "dblDagger"
  1741.         "en-dash"
  1742.         "em-dash"
  1743.         "texLogo"
  1744.         "latexLogo"
  1745.         "copyright"
  1746.         "pounds"
  1747.         "today"
  1748.         "(-"
  1749.         "quotes"
  1750.         "dblQuotes"
  1751.         "(-"
  1752.         "note"
  1753.         "footnote"
  1754.         "(-"
  1755.         "label"
  1756.         "crossRef"
  1757.         "pageRef"
  1758.         "citation"
  1759.         "(-"
  1760.         "item"
  1761.         "bibitem"
  1762.         }
  1763.     }
  1764.     
  1765.     "(-"
  1766.     
  1767.     {menu -n mathModes -p interpretMenuItem {
  1768.         "texMath"
  1769.         "texDisplaymath"
  1770.         "(-"
  1771.         "latexMath"
  1772.         "latexDisplaymath"}
  1773.     }
  1774.     
  1775.     {menu -n mathEnvironments -p interpretMenuItem {
  1776.         "math"
  1777.         "displaymath"
  1778.         "equation"
  1779.         "(-"
  1780.         "array…"
  1781.         "eqnarray…"
  1782.         "eqnarray*…"
  1783.         "(-"
  1784.         "general…"}
  1785.     }
  1786.     
  1787.     {menu -n Formulas -p interpretMenuItem {
  1788.         "subscript"
  1789.         "superscript"
  1790.         "fraction"
  1791.         "squareRoot"
  1792.         "nthRoot"
  1793.         "(-"
  1794.         "oneParameter…"
  1795.         "twoParameters…"
  1796.         }
  1797.     }
  1798.     
  1799.     {menu -n Greek -p interpretMenuItem {
  1800.         "alpha"
  1801.         "beta"
  1802.         "gamma"
  1803.         "delta"
  1804.         "epsilon"
  1805.         "zeta"
  1806.         "eta"
  1807.         "theta"
  1808.         "iota"
  1809.         "kappa"
  1810.         "lambda"
  1811.         "mu"
  1812.         "nu"
  1813.         "xi"
  1814.         "pi"
  1815.         "rho"
  1816.         "sigma"
  1817.         "tau"
  1818.         "upsilon"
  1819.         "phi"
  1820.         "chi"
  1821.         "psi"
  1822.         "omega"
  1823.         }
  1824.     }
  1825.     {menu -n Greek2 -p interpretMenuItem {
  1826.         "capGamma"
  1827.         "capDelta"
  1828.         "capTheta"
  1829.         "capLambda"
  1830.         "capXi"
  1831.         "capPi"
  1832.         "capSigma"
  1833.         "capUpsilon"
  1834.         "capPhi"
  1835.         "capPsi"
  1836.         "capOmega"
  1837.         "(-"
  1838.         "varEpsilon"
  1839.         "varTheta"
  1840.         "varPi"
  1841.         "varRho"
  1842.         "varSigma"
  1843.         "varPhi"
  1844.         }
  1845.     }
  1846.         
  1847.     {menu -n BinaryOperators -p interpretMenuItem {
  1848.         "plusOrMinus"
  1849.         "minusOrPlus"
  1850.         "multiply"
  1851.         "divide"
  1852.         "asterisk"
  1853.         "star"
  1854.         "centerDot"
  1855.         "bullet"
  1856.         "circle"
  1857.         "bigCircle"
  1858.         "intersection"
  1859.         "union"
  1860.         "logicalAnd"
  1861.         "logicalOr"
  1862.         "setMinus"
  1863.         }
  1864.     }
  1865.     
  1866.     {menu -n Relations -p interpretMenuItem {
  1867.         "notEqual"
  1868.         "lessOrEqual"
  1869.         "greaterOrEqual"
  1870.         "subset"
  1871.         "superset"
  1872.         "subsetOrEqual"
  1873.         "supersetOrEqual"
  1874.         "elementOf"
  1875.         "equivalent"
  1876.         "similar"
  1877.         "similarEqual"
  1878.         "dotEqual"
  1879.         "approximate"
  1880.         "congruent"
  1881.         }
  1882.     }
  1883.     
  1884.     {menu -n LargeOperators -p interpretMenuItem {
  1885.         "sum"
  1886.         "product"
  1887.         "integral"
  1888.         "bigUnion"
  1889.         "bigIntersection"
  1890.         "bigAnd"
  1891.         "bigOr"
  1892.         }
  1893.     }
  1894.     
  1895.     {menu -n Arrows -p interpretMenuItem {
  1896.         "mapsTo"
  1897.         "leftArrow"
  1898.         "rightArrow"
  1899.         "left-rightArrow"
  1900.         "dblLeftArrow"
  1901.         "dblRightArrow"
  1902.         "dblLeft-rightArrow"
  1903.         }
  1904.     }
  1905.     
  1906.     {menu -n Dots -p interpretMenuItem {
  1907.         "centerDot"
  1908.         "bullet"
  1909.         "(-"
  1910.         "ellipsis"
  1911.         "centerDots"
  1912.         "verticalDots"
  1913.         "diagonalDots"
  1914.         }
  1915.     }
  1916.     
  1917.     {menu -n Symbols -p interpretMenuItem {
  1918.         "aleph"
  1919.         "emptySet"
  1920.         "negation"
  1921.         "forAll"
  1922.         "exists"
  1923.         "scriptL"
  1924.         "nabla"
  1925.         "partial"
  1926.         "infinity"
  1927.         "backslash"
  1928.         "angle"
  1929.         "box"
  1930.         "diamond"
  1931.         "triangle"
  1932.         }
  1933.     }
  1934.         
  1935.     {menu -n (Functions -p interpretMenuItem {
  1936.         }
  1937.     }
  1938.  
  1939.     {menu -n Delimiters -p interpretMenuItem {
  1940.         "parentheses"
  1941.         "brackets"
  1942.         "braces"
  1943.         "absoluteValue"
  1944.         "otherDelims…"
  1945.         "(-"
  1946.         "half-openInterval"
  1947.         "half-closedInterval"
  1948.         "(-"
  1949.         "bigParentheses"
  1950.         "bigBrackets"
  1951.         "bigBraces"
  1952.         "bigAbsoluteValue"
  1953.         "otherBigDelims…"
  1954.         "(-"
  1955.         "bigLeftBrace"
  1956.         "otherMixedBigDelims…"
  1957.         }
  1958.     }
  1959.         
  1960.     {menu -n mathAccents -p interpretMenuItem {
  1961.         "hat"
  1962.         "check"
  1963.         "breve"
  1964.         "acuteAccent"
  1965.         "graveAccent"
  1966.         "tilde"
  1967.         "bar"
  1968.         "vector"
  1969.         "dot"
  1970.         "dblDot"
  1971.         "(-"
  1972.         "wideHat"
  1973.         "wideTilde"
  1974.         "(-"
  1975.         "dotlessI"
  1976.         "dotlessJ"
  1977.         }
  1978.     }
  1979.     
  1980.     {menu -n Grouping -p interpretMenuItem {
  1981.         "underline"
  1982.         "overline"
  1983.         "underbrace"
  1984.         "overbrace"
  1985.         "(-"
  1986.         "stack"
  1987.         }
  1988.     }
  1989.     
  1990.     {menu -n Spacing -p interpretMenuItem {
  1991.         "thin"
  1992.         "negThin"
  1993.         "medium"
  1994.         "thick"
  1995.         "(-"
  1996.         "quad"
  1997.         "dblQuad"
  1998.         }
  1999.     }
  2000.     
  2001.     {menu -n MathStyle -p interpretMenuItem {
  2002.         "mathItalic"
  2003.         "calligraphic"
  2004.         "(-"
  2005.         "(fraktur"
  2006.         "(script"
  2007.         "(blackboardBold"
  2008.         "(-"
  2009.         "displayStyle"
  2010.         "textStyle"
  2011.         "scriptStyle"
  2012.         "scriptscriptStyle"
  2013.         }
  2014.     }
  2015. }
  2016.  
  2017.  
  2018. #############################################################################
  2019. #
  2020. # Special Key Bindings.
  2021. #
  2022. # abbreviations:  <o> = option, <z> = control, <s> = shift, <c> = command
  2023. #
  2024. #############################################################################
  2025.  
  2026. bind 0x14 <z> commentLine Tex
  2027. if {$optionIsMeta == "0"} then {
  2028.  
  2029.     #  use option for macros, escape for meta
  2030.  
  2031.     bind    'a'    <o>    alpha    "Tex"
  2032.     bind    'a'    <os>    angle    "Tex"
  2033.     bind    'a'    <oz>    forAll    "Tex"
  2034.     bind    'a'    <co>    acuteAccent    "Tex"
  2035.     
  2036.     bind    'b'    <o>    beta    "Tex"
  2037.     bind    'b'    <oz>    box    "Tex"
  2038.     bind    'b'    <co>    bar    "Tex"
  2039.     bind    'b'    <cs>    bold    "Tex"
  2040.     
  2041.     bind    'c'    <o>    chi    "Tex"
  2042.     bind    'c'    <co>    check    "Tex"
  2043.     bind    'c'    <cs>    citation    "Tex"
  2044.     bind    'c'    <cso>    calligraphic    "Tex"
  2045.     
  2046.     bind    'd'    <o>    delta    "Tex"
  2047.     bind    'd'    <os>    capDelta    "Tex"
  2048.     bind    'd'    <oz>    diamond    "Tex"
  2049.     bind    'd'    <co>    dot    "Tex"
  2050.     bind    'd'    <cso>    dblDot    "Tex"
  2051.     
  2052.     bind    'e'    <o>    epsilon    "Tex"
  2053.     bind    'e'    <os>    exists    "Tex"
  2054.     bind    'e'    <oz>    varEpsilon    "Tex"
  2055.     bind    'e'    <cs>    emphatic    "Tex"
  2056.     
  2057.     bind    'f'    <o>    phi    "Tex"
  2058.     bind    'f'    <os>    capPhi    "Tex"
  2059.     bind    'f'    <oz>    varPhi    "Tex"
  2060.     bind    'f'    <co>    fraction    "Tex"
  2061.     bind    'f'    <cs>    footnote    "Tex"
  2062.     
  2063.     bind    'g'    <o>    gamma    "Tex"
  2064.     bind    'g'    <os>    capGamma    "Tex"
  2065.     bind    'g'    <oz>    copyright    "Tex"
  2066.     bind    'g'    <co>    graveAccent    "Tex"
  2067.     
  2068.     bind    'h'    <o>    eta    "Tex"
  2069.     bind    'h'    <co>    hat    "Tex"
  2070.     bind    'h'    <cs>    smallCaps    "Tex"
  2071.     bind    'h'    <cso>    wideHat    "Tex"
  2072.     
  2073.     bind    'i'    <o>    iota    "Tex"
  2074.     bind    'i'    <oz>    dotlessI    "Tex"
  2075.     bind    'i'    <co>    integral    "Tex"
  2076.     bind    'i'    <cs>    italic    "Tex"
  2077.     bind    'i'    <cso>    mathItalic    "Tex"
  2078.     
  2079.     bind    'j'    <o>    partial    "Tex"
  2080.     bind    'j'    <oz>    dotlessJ    "Tex"
  2081.     
  2082.     bind    'k'    <o>    kappa    "Tex"
  2083.     
  2084.     bind    'l'    <o>    lambda    "Tex"
  2085.     bind    'l'    <os>    capLambda    "Tex"
  2086.     bind    'l'    <oz>    scriptL    "Tex"
  2087.     bind    'l'    <cs>    label    "Tex"
  2088.     
  2089.     bind    'm'    <o>    mu    "Tex"
  2090.     bind    'm'    <oz>    mapsTo    "Tex"
  2091.     bind    'm'    <co>    mbox    "Tex"
  2092.     bind    'm'    <cs>    mbox    "Tex"
  2093.     
  2094.     bind    'n'    <o>    nu    "Tex"
  2095.     bind    'n'    <os>    aleph    "Tex"
  2096.     bind    'n'    <oz>    intersection    "Tex"
  2097.     bind    'n'    <co>    nthRoot    "Tex"
  2098.     bind    'n'    <cs>    note    "Tex"
  2099.     
  2100.     bind    'o'    <o>    circle    "Tex"
  2101.     bind    'o'    <os>    bigCircle    "Tex"
  2102.     bind    'o'    <co>    overline    "Tex"
  2103.     bind    'o'    <cso>    overbrace    "Tex"
  2104.     
  2105.     bind    'p'    <o>    pi    "Tex"
  2106.     bind    'p'    <os>    capPi    "Tex"
  2107.     bind    'p'    <oz>    varPi    "Tex"
  2108.     bind    'p'    <co>    product    "Tex"
  2109.     bind    'p'    <cs>    pageRef    "Tex"
  2110.     
  2111.     bind    'q'    <o>    theta    "Tex"
  2112.     bind    'q'    <os>    capTheta    "Tex"
  2113.     bind    'q'    <oz>    varTheta    "Tex"
  2114.     
  2115.     bind    'r'    <o>    rho    "Tex"
  2116.     bind    'r'    <oz>    varRho    "Tex"
  2117.     bind    'r'    <co>    squareRoot    "Tex"
  2118.     bind    'r'    <cs>    roman    "Tex"
  2119.     
  2120.     bind    's'    <o>    sigma    "Tex"
  2121.     bind    's'    <os>    capSigma    "Tex"
  2122.     bind    's'    <oz>    varSigma    "Tex"
  2123.     bind    's'    <co>    sum    "Tex"
  2124.     bind    's'    <cs>    slanted    "Tex"
  2125.     
  2126.     bind    't'    <o>    tau    "Tex"
  2127.     bind    't'    <os>    dagger    "Tex"
  2128.     bind    't'    <oz>    triangle    "Tex"
  2129.     bind    't'    <co>    tilde    "Tex"
  2130.     bind    't'    <cs>    typewriter    "Tex"
  2131.     bind    't'    <cso>    wideTilde    "Tex"
  2132.     
  2133.     bind    'u'    <o>    upsilon    "Tex"
  2134.     bind    'u'    <os>    capUpsilon    "Tex"
  2135.     bind    'u'    <oz>    union    "Tex"
  2136.     bind    'u'    <co>    underline    "Tex"
  2137.     bind    'u'    <cso>    underbrace    "Tex"
  2138.     
  2139.     bind    'v'    <o>    nabla    "Tex"
  2140.     bind    'v'    <oz>    logicalOr    "Tex"
  2141.     bind    'v'    <co>    vector    "Tex"
  2142.     
  2143.     bind    'w'    <o>    omega    "Tex"
  2144.     bind    'w'    <os>    capOmega    "Tex"
  2145.     bind    'w'    <oz>    logicalAnd    "Tex"
  2146.     bind    'w'    <cs>    sansSerif    "Tex"
  2147.     
  2148.     bind    'x'    <o>    xi    "Tex"
  2149.     bind    'x'    <os>    capXi    "Tex"
  2150.     bind    'x'    <oz>    multiply    "Tex"
  2151.     bind    'x'    <cs>    crossRef    "Tex"
  2152.     
  2153.     bind    'y'    <o>    psi    "Tex"
  2154.     bind    'y'    <os>    capPsi    "Tex"
  2155.     
  2156.     bind    'z'    <o>    zeta    "Tex"
  2157.     
  2158.     bind    '\ '    <o>    thin    "Tex"
  2159.     bind    '\ '    <os>    negThin    "Tex"
  2160.     bind    '\ '    <oz>    medium    "Tex"
  2161.     bind    '\ '    <co>    thick    "Tex"
  2162.     bind    '\ '    <cs>    quad    "Tex"
  2163.     bind    '\ '    <cso>    dblQuad    "Tex"
  2164.     
  2165.     bind    ','    <o>    lessOrEqual    "Tex"
  2166.     bind    ','    <os>    subset    "Tex"
  2167.     bind    ','    <oz>    subsetOrEqual    "Tex"
  2168.     bind    ','    <co>    subscript    "Tex"
  2169.     
  2170.     bind    '.'    <o>    greaterOrEqual    "Tex"
  2171.     bind    '.'    <os>    superset    "Tex"
  2172.     bind    '.'    <oz>    supersetOrEqual    "Tex"
  2173.     bind    '.'    <co>    superscript    "Tex"
  2174.     
  2175.     bind    '/'    <o>    divide    "Tex"
  2176.     bind    '/'    <co>    fraction    "Tex"
  2177.     
  2178.     bind    '\;'    <o>    ellipsis    "Tex"
  2179.     bind    '\;'    <os>    centerDots    "Tex"
  2180.     bind    '\;'    <oz>    verticalDots    "Tex"
  2181.     bind    '\;'    <co>    diagonalDots    "Tex"
  2182.     
  2183.     # apostrophe:
  2184.     bind    0x27    <co>    acuteAccent    "Tex"
  2185.     bind    0x27    <cs>    quotes    "Tex"
  2186.     bind    0x27    <cso>    dblQuotes    "Tex"
  2187.  
  2188.     bind    '\['    <o>    brackets    "Tex"
  2189.     bind    '\['    <os>    braces    "Tex"
  2190.     bind    '\['    <co>    bigBrackets    "Tex"
  2191.     bind    '\['    <cso>    bigBraces    "Tex"
  2192.  
  2193.     bind    '\]'    <o>    displayStyle    "Tex"
  2194.     bind    '\]'    <os>    textStyle    "Tex"
  2195.     bind    '\]'    <oz>    scriptStyle    "Tex"
  2196.     bind    '\]'    <co>    scriptscriptStyle    "Tex"
  2197.     bind    '\]'    <cso>    bigLeftBrace    "Tex"
  2198.     
  2199.     bind    '\'    <o>    backslash    "Tex"
  2200.     bind    '\'    <os>    absoluteValue    "Tex"
  2201.     bind    '\'    <oz>    setMinus    "Tex"
  2202.     bind    '\'    <co>    bigAbsoluteValue    "Tex"
  2203.     bind    '\'    <cs>    "oneParameter"    "Tex"
  2204.     bind    '\'    <cso>    "twoParameters"    "Tex"
  2205.     
  2206.     bind    '`'    <co>    graveAccent    "Tex"
  2207.     bind    '`'    <cso>    tilde    "Tex"
  2208.         
  2209.     # Change to latexMath and latexDisplaymath, if desired:
  2210.     bind    '4'    <co>    texMath    "Tex"
  2211.     bind    '4'    <cso>    texDisplaymath    "Tex"
  2212.     
  2213.     bind    '5'    <o>    infinity    "Tex"
  2214.     
  2215.     bind    '6'    <o>    sectionMark    "Tex"
  2216.     bind    '6'    <co>    superscript    "Tex"
  2217.     
  2218.     bind    '7'    <o>    paragraphMark    "Tex"
  2219.     
  2220.     bind    '8'    <o>    bullet    "Tex"
  2221.     bind    '8'    <os>    asterisk    "Tex"
  2222.     bind    '8'    <oz>    centerDot    "Tex"
  2223.     
  2224.     bind    '9'    <os>    parentheses    "Tex"
  2225.     bind    '9'    <co>    bigParentheses    "Tex"
  2226.     
  2227.     bind    '0'    <oz>    emptySet    "Tex"
  2228.     
  2229.     bind    '-'    <o>    similar    "Tex"
  2230.     bind    '-'    <os>    minusOrPlus    "Tex"
  2231.     bind    '-'    <oz>    negation    "Tex"
  2232.     bind    '-'    <co>    subscript    "Tex"
  2233.     
  2234.     bind    '='    <o>    notEqual    "Tex"
  2235.     bind    '='    <os>    plusOrMinus    "Tex"
  2236.     bind    '='    <oz>    approximate    "Tex"
  2237.     bind    '='    <co>    bar    "Tex"
  2238.     
  2239.     bind    F5    <o>    math    "Tex"
  2240.     bind    F5    <os>    displaymath    "Tex"
  2241.     bind    F5    <oz>    equation    "Tex"
  2242.     
  2243.     bind    F6    <o>    "myArray"    "Tex"
  2244.     bind    F6    <os>    "eqnarray"    "Tex"
  2245.     bind    F6    <oz>    "eqnarrayStar"    "Tex"
  2246.     
  2247.     bind    F7    <o>    "enumerate"    "Tex"
  2248.     bind    F7    <os>    "itemize"    "Tex"
  2249.     bind    F7    <oz>    "description"    "Tex"
  2250.     
  2251.     bind    F8    <o>    "tabular"    "Tex"
  2252.     bind    F8    <os>    tabbing    "Tex"
  2253.     
  2254.     bind    F9    <o>    figure    "Tex"
  2255.     bind    F9    <os>    table    "Tex"
  2256.     bind    F9    <oz>    slide    "Tex"
  2257.     
  2258.     bind    F10    <o>    verbatim    "Tex"
  2259.     bind    F10    <os>    quote    "Tex"
  2260.     bind    F10    <oz>    quotation    "Tex"
  2261.     bind    F10    <co>    verse    "Tex"
  2262.     
  2263.     bind    F11    <o>    "index"    "Tex"
  2264.     bind    F11    <os>    "bibliography"    "Tex"
  2265.     
  2266.     bind    F12    <o>    "general"    "Tex"
  2267.     
  2268.     # tab:
  2269.     bind    0x30    nextTabStop    "Tex"
  2270.     bind    0x30    <s>     previousTabStop    "Tex"
  2271.     
  2272. } else {
  2273.     
  2274.     #    bind    macros    to    option-control,    use    option    as    meta
  2275.     
  2276.     bind    'a'    <zo>    alpha    "Tex"
  2277.     bind    'a'    <zos>    angle    "Tex"
  2278.     # bind    'a'    <oz>    forAll    "Tex"
  2279.     bind    'a'    <zco>    acuteAccent    "Tex"
  2280.     
  2281.     bind    'b'    <zo>    beta    "Tex"
  2282.     # bind    'b'    <oz>    box    "Tex"
  2283.     bind    'b'    <zco>    bar    "Tex"
  2284.     bind    'b'    <zcs>    bold    "Tex"
  2285.     
  2286.     bind    'c'    <zo>    chi    "Tex"
  2287.     bind    'c'    <zco>    check    "Tex"
  2288.     bind    'c'    <zcs>    citation    "Tex"
  2289.     bind    'c'    <zcso>    calligraphic    "Tex"
  2290.     
  2291.     bind    'd'    <zo>    delta    "Tex"
  2292.     bind    'd'    <zos>    capDelta    "Tex"
  2293.     # bind    'd'    <oz>    diamond    "Tex"
  2294.     bind    'd'    <zco>    dot    "Tex"
  2295.     bind    'd'    <zcso>    dblDot    "Tex"
  2296.     
  2297.     bind    'e'    <zo>    epsilon    "Tex"
  2298.     bind    'e'    <zos>    exists    "Tex"
  2299.     # bind    'e'    <oz>    varEpsilon    "Tex"
  2300.     bind    'e'    <zcs>    emphatic    "Tex"
  2301.     
  2302.     bind    'f'    <zo>    phi    "Tex"
  2303.     bind    'f'    <zos>    capPhi    "Tex"
  2304.     # bind    'f'    <oz>    varPhi    "Tex"
  2305.     bind    'f'    <zco>    fraction    "Tex"
  2306.     bind    'f'    <zcs>    footnote    "Tex"
  2307.     
  2308.     bind    'g'    <zo>    gamma    "Tex"
  2309.     bind    'g'    <zos>    capGamma    "Tex"
  2310.     # bind    'g'    <oz>    copyright    "Tex"
  2311.     bind    'g'    <zco>    graveAccent    "Tex"
  2312.     
  2313.     bind    'h'    <zo>    eta    "Tex"
  2314.     bind    'h'    <zco>    hat    "Tex"
  2315.     bind    'h'    <zcs>    smallCaps    "Tex"
  2316.     bind    'h'    <zcso>    wideHat    "Tex"
  2317.     
  2318.     bind    'i'    <zo>    iota    "Tex"
  2319.     # bind    'i'    <oz>    dotlessI    "Tex"
  2320.     bind    'i'    <zco>    integral    "Tex"
  2321.     bind    'i'    <zcs>    italic    "Tex"
  2322.     bind    'i'    <zcso>    mathItalic    "Tex"
  2323.     
  2324.     bind    'j'    <zo>    partial    "Tex"
  2325.     # bind    'j'    <oz>    dotlessJ    "Tex"
  2326.     
  2327.     bind    'k'    <zo>    kappa    "Tex"
  2328.     
  2329.     bind    'l'    <zo>    lambda    "Tex"
  2330.     bind    'l'    <zos>    capLambda    "Tex"
  2331.     # bind    'l'    <oz>    scriptL    "Tex"
  2332.     bind    'l'    <zcs>    label    "Tex"
  2333.     
  2334.     bind    'm'    <zo>    mu    "Tex"
  2335.     # bind    'm'    <oz>    mapsTo    "Tex"
  2336.     bind    'm'    <zco>    mbox    "Tex"
  2337.     bind    'm'    <zcs>    mbox    "Tex"
  2338.     
  2339.     bind    'n'    <zo>    nu    "Tex"
  2340.     bind    'n'    <zos>    aleph    "Tex"
  2341.     # bind    'n'    <oz>    intersection    "Tex"
  2342.     bind    'n'    <zco>    nthRoot    "Tex"
  2343.     bind    'n'    <zcs>    note    "Tex"
  2344.     
  2345.     bind    'o'    <zo>    circle    "Tex"
  2346.     bind    'o'    <zos>    bigCircle    "Tex"
  2347.     bind    'o'    <zco>    overline    "Tex"
  2348.     bind    'o'    <zcso>    overbrace    "Tex"
  2349.     
  2350.     bind    'p'    <zo>    pi    "Tex"
  2351.     bind    'p'    <zos>    capPi    "Tex"
  2352.     # bind    'p'    <oz>    varPi    "Tex"
  2353.     bind    'p'    <zco>    product    "Tex"
  2354.     bind    'p'    <zcs>    pageRef    "Tex"
  2355.     
  2356.     bind    'q'    <zo>    theta    "Tex"
  2357.     bind    'q'    <zos>    capTheta    "Tex"
  2358.     # bind    'q'    <oz>    varTheta    "Tex"
  2359.     
  2360.     bind    'r'    <zo>    rho    "Tex"
  2361.     # bind    'r'    <oz>    varRho    "Tex"
  2362.     bind    'r'    <zco>    squareRoot    "Tex"
  2363.     bind    'r'    <zcs>    roman    "Tex"
  2364.     
  2365.     bind    's'    <zo>    sigma    "Tex"
  2366.     bind    's'    <zos>    capSigma    "Tex"
  2367.     # bind    's'    <oz>    varSigma    "Tex"
  2368.     bind    's'    <zco>    sum    "Tex"
  2369.     bind    's'    <zcs>    slanted    "Tex"
  2370.     
  2371.     bind    't'    <zo>    tau    "Tex"
  2372.     bind    't'    <zos>    dagger    "Tex"
  2373.     # bind    't'    <oz>    triangle    "Tex"
  2374.     bind    't'    <zco>    tilde    "Tex"
  2375.     bind    't'    <zcs>    typewriter    "Tex"
  2376.     bind    't'    <zcso>    wideTilde    "Tex"
  2377.     
  2378.     bind    'u'    <zo>    upsilon    "Tex"
  2379.     bind    'u'    <zos>    capUpsilon    "Tex"
  2380.     # bind    'u'    <oz>    union    "Tex"
  2381.     bind    'u'    <zco>    underline    "Tex"
  2382.     bind    'u'    <zcso>    underbrace    "Tex"
  2383.     
  2384.     bind    'v'    <zo>    nabla    "Tex"
  2385.     # bind    'v'    <oz>    logicalOr    "Tex"
  2386.     bind    'v'    <zco>    vector    "Tex"
  2387.     
  2388.     bind    'w'    <zo>    omega    "Tex"
  2389.     bind    'w'    <zos>    capOmega    "Tex"
  2390.     # bind    'w'    <oz>    logicalAnd    "Tex"
  2391.     bind    'w'    <zcs>    sansSerif    "Tex"
  2392.     
  2393.     bind    'x'    <zo>    xi    "Tex"
  2394.     bind    'x'    <zos>    capXi    "Tex"
  2395.     # bind    'x'    <oz>    multiply    "Tex"
  2396.     bind    'x'    <zcs>    crossRef    "Tex"
  2397.     
  2398.     bind    'y'    <zo>    psi    "Tex"
  2399.     bind    'y'    <zos>    capPsi    "Tex"
  2400.     
  2401.     bind    'z'    <zo>    zeta    "Tex"
  2402.     
  2403.     bind    '\ '    <zo>    thin    "Tex"
  2404.     bind    '\ '    <zos>    negThin    "Tex"
  2405.     # bind    '\ '    <oz>    medium    "Tex"
  2406.     bind    '\ '    <zco>    thick    "Tex"
  2407.     bind    '\ '    <zcs>    quad    "Tex"
  2408.     bind    '\ '    <zcso>    dblQuad    "Tex"
  2409.     
  2410.     bind    ','    <zo>    lessOrEqual    "Tex"
  2411.     bind    ','    <zos>    subset    "Tex"
  2412.     # bind    ','    <oz>    subsetOrEqual    "Tex"
  2413.     bind    ','    <zco>    subscript    "Tex"
  2414.     
  2415.     bind    '.'    <zo>    greaterOrEqual    "Tex"
  2416.     bind    '.'    <zos>    superset    "Tex"
  2417.     # bind    '.'    <oz>    supersetOrEqual    "Tex"
  2418.     bind    '.'    <zco>    superscript    "Tex"
  2419.     
  2420.     bind    '/'    <zo>    divide    "Tex"
  2421.     bind    '/'    <zco>    fraction    "Tex"
  2422.     
  2423.     bind    '\;'    <zo>    ellipsis    "Tex"
  2424.     bind    '\;'    <zos>    centerDots    "Tex"
  2425.     # bind    '\;'    <oz>    verticalDots    "Tex"
  2426.     bind    '\;'    <zco>    diagonalDots    "Tex"
  2427.     
  2428.     # apostrophe:
  2429.     bind    0x27    <zco>    acuteAccent    "Tex"
  2430.     bind    0x27    <zcs>    quotes    "Tex"
  2431.     bind    0x27    <zcso>    dblQuotes    "Tex"
  2432.  
  2433.     bind    '\['    <zo>    brackets    "Tex"
  2434.     bind    '\['    <zos>    braces    "Tex"
  2435.     bind    '\['    <zco>    bigBrackets    "Tex"
  2436.     bind    '\['    <zcso>    bigBraces    "Tex"
  2437.  
  2438.     bind    '\]'    <zo>    displayStyle    "Tex"
  2439.     bind    '\]'    <zos>    textStyle    "Tex"
  2440.     # bind    '\]'    <oz>    scriptStyle    "Tex"
  2441.     bind    '\]'    <zco>    scriptscriptStyle    "Tex"
  2442.     bind    '\]'    <zcso>    bigLeftBrace    "Tex"
  2443.     
  2444.     bind    '\'    <zo>    backslash    "Tex"
  2445.     bind    '\'    <zos>    absoluteValue    "Tex"
  2446.     # bind    '\'    <oz>    setMinus    "Tex"
  2447.     bind    '\'    <zco>    bigAbsoluteValue    "Tex"
  2448.     bind    '\'    <zcs>    "oneParameter"    "Tex"
  2449.     bind    '\'    <zcso>    "twoParameters"    "Tex"
  2450.     
  2451.     bind    '`'    <zco>    graveAccent    "Tex"
  2452.     bind    '`'    <zcso>    tilde    "Tex"
  2453.     
  2454.     # Change to latexMath and latexDisplaymath, if desired:
  2455.     bind    '4'    <zco>    texMath    "Tex"
  2456.     bind    '4'    <zcso>    texDisplaymath    "Tex"
  2457.     
  2458.     bind    '5'    <zo>    infinity    "Tex"
  2459.     
  2460.     bind    '6'    <zo>    sectionMark    "Tex"
  2461.     bind    '6'    <zco>    superscript    "Tex"
  2462.     
  2463.     bind    '7'    <zo>    paragraphMark    "Tex"
  2464.     
  2465.     bind    '8'    <zo>    bullet    "Tex"
  2466.     bind    '8'    <zos>    asterisk    "Tex"
  2467.     # bind    '8'    <oz>    centerDot    "Tex"
  2468.     
  2469.     bind    '9'    <zos>    parentheses    "Tex"
  2470.     bind    '9'    <zco>    bigParentheses    "Tex"
  2471.     
  2472.     # bind    '0'    <oz>    emptySet    "Tex"
  2473.     
  2474.     bind    '-'    <zo>    similar    "Tex"
  2475.     bind    '-'    <zos>    minusOrPlus    "Tex"
  2476.     # bind    '-'    <oz>    negation    "Tex"
  2477.     bind    '-'    <zco>    subscript    "Tex"
  2478.     
  2479.     bind    '='    <zo>    notEqual    "Tex"
  2480.     bind    '='    <zos>    plusOrMinus    "Tex"
  2481.     # bind    '='    <oz>    approximate    "Tex"
  2482.     bind    '='    <zco>    bar    "Tex"
  2483.     
  2484.     bind    F5    <zo>    math    "Tex"
  2485.     bind    F5    <zos>    displaymath    "Tex"
  2486.     # bind    F5    <oz>    equation    "Tex"
  2487.     
  2488.     bind    F6    <zo>    "myArray"    "Tex"
  2489.     bind    F6    <zos>    "eqnarray"    "Tex"
  2490.     # bind    F6    <oz>    "eqnarrayStar"    "Tex"
  2491.     
  2492.     bind    F7    <zo>    "enumerate"    "Tex"
  2493.     bind    F7    <zos>    "itemize"    "Tex"
  2494.     # bind    F7    <oz>    "description"    "Tex"
  2495.     
  2496.     bind    F8    <zo>    "tabular"    "Tex"
  2497.     bind    F8    <zos>    tabbing    "Tex"
  2498.     
  2499.     bind    F9    <zo>    figure    "Tex"
  2500.     bind    F9    <zos>    table    "Tex"
  2501.     # bind    F9    <oz>    slide    "Tex"
  2502.     
  2503.     bind    F10    <zo>    verbatim    "Tex"
  2504.     bind    F10    <zos>    quote    "Tex"
  2505.     # bind    F10    <oz>    quotation    "Tex"
  2506.     bind    F10    <zco>    verse    "Tex"
  2507.     
  2508.     bind    F11    <zo>    "index"    "Tex"
  2509.     bind    F11    <zos>    "bibliography"    "Tex"
  2510.     
  2511.     bind    F12    <zo>    "general"    "Tex"
  2512.  
  2513.     # tab:
  2514.     bind    0x30    nextTabStop    "Tex"
  2515.     bind    0x30    <s>     previousTabStop    "Tex"
  2516.     
  2517. }
  2518.  
  2519.  
  2520.